package com.example.host.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.host.domain.ComputerInfo;
import com.example.host.mapper.ComputerInfoMapper;
import com.example.host.service.ReceiveAliveMsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ReceiveAliveMsgServiceImpl implements ReceiveAliveMsgService {
    @Autowired
    ComputerInfoMapper computerInfoMapper;
    
    @Override
    public void insertOrUpdateRemoteComputerStatus(ComputerInfo computerInfo) {
        QueryWrapper<ComputerInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("DEVICE_CLIENT_ID",computerInfo.getDeviceClientId());
        if (computerInfoMapper.selectOne(queryWrapper)==null){
            computerInfoMapper.insert(computerInfo);
        } else {
            computerInfoMapper.update(computerInfo,queryWrapper);
        }
    }
}
